package com.example.demo.controller;

import com.example.demo.annotation.Limit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@Slf4j
@Api(value = "请求去重",tags = "测试")
@RequestMapping("/app")
public class demo1 {

    @GetMapping("/test/accessLimit")
    public String testAccessLimit(@RequestParam("userId") String userId) {
        System.out.println("okoko");
        return "正常返回1";
    }

    @GetMapping("/res2")
    @ApiOperation(value = "请求去重1")
    public String testAccessLimit2() {
        System.out.println("启动成功。。。");
        return "正常返回22222";
    }

    @Limit(key = "cachingTest", permitsPerSecond = 1, timeout = 2, msg = "当前排队人数较多，请稍后再试！")
    @GetMapping("cachingTest")
    public String cachingTest(){
//        log.info("------读取本地------");
//        List<String> list = new ArrayList<>();
//        list.add("蜡笔小新");
//        list.add("哆啦A梦");
//        list.add("四驱兄弟");
        System.out.println("我开始了。。。");
        return "正确1111";
    }

}


